home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Documentation / Tech Notes & Articles / Recipes / ODExtension recipes < prev    next >
Encoding:
Text File  |  1995-07-11  |  1.9 KB  |  27 lines  |  [TEXT/ttxt]

  1. ODExtension Recipes
  2. by The OpenDoc Design Team
  3. April 20. 1995
  4.  
  5.  
  6. © 1993-1995  Apple Computer, Inc. All Rights Reserved.
  7. Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
  8. Mac and OpenDoc are trademarks of Apple Computer, Inc.  (Palatino/10/Plain)
  9.  
  10.  
  11. Clients of extensions
  12.  
  13. To test for the availability of a particular extension on a particular object, use HasExtension. To acquire a reference to an extension, use GetExtension. When done with an extension, call the extension's Release method.
  14.  
  15.  
  16. ODExtension subclasses
  17.  
  18. When the refcount of a an ODExtension subclass drops to 0, the extension should call its base's ReleaseExtension method to inform it that this extension is going away. Of course, this shouldn't happen if the base is invalid, i.e., once the extension's BaseRemoved method has been called.
  19.  
  20.  
  21. Owners of extensions (bases)
  22.  
  23. Any OpenDoc class that descends from ODObject can support extensions. Three methods of ODObject support extensions, HasExtension, GetExtension and ReleaseExtension. If a base  wishes to return the same object for all calls to GetExtension, the owner should increment the refCount of the extension each time GetExtension is called. The base then assures that the extension will not self-destruct until all other references the extension are released and the base itself calls Release on the extension. If the owner wishes to return a new instantiation of the extension for each call to GetExtension, it should simply create and return a new instance when GetExtension is called.
  24.  
  25. When ReleaseExtension is called, the owner should remove any reference to that extension that it may have cached (in a list of extensions, for example) and delete the extension object.
  26.  
  27. An owner should take care to keep a reference to any extension objects that it creates so that it can call BaseRemoved on all of its extensions when it is about to go away.